home *** CD-ROM | disk | FTP | other *** search
/ Champak 43 / Vol 43.iso / games / phit.swf / scripts / __Packages / CCVAxisAlignedBox.as < prev    next >
Encoding:
Text File  |  2007-07-13  |  2.1 KB  |  90 lines

  1. class CCVAxisAlignedBox extends CCollisionVolume
  2. {
  3.    var m_width;
  4.    var m_height;
  5.    var m_body;
  6.    function CCVAxisAlignedBox(body, width, height)
  7.    {
  8.       super(body);
  9.       this.m_width = width;
  10.       this.m_height = height;
  11.       if(body)
  12.       {
  13.          if(!width)
  14.          {
  15.             this.m_width = body._width;
  16.          }
  17.          if(!height)
  18.          {
  19.             this.m_height = body._height;
  20.          }
  21.       }
  22.    }
  23.    function get _halfWidth()
  24.    {
  25.       return this.m_width * 0.5;
  26.    }
  27.    function get _halfHeight()
  28.    {
  29.       return this.m_height * 0.5;
  30.    }
  31.    function get _boundingRadius()
  32.    {
  33.       return Math.max(this._halfHeight,this._halfWidth);
  34.    }
  35.    function get _center()
  36.    {
  37.       return this.m_body._location;
  38.    }
  39.    function get _topLeftCorner()
  40.    {
  41.       return new Vector2D(this.m_body._x - this.m_width * 0.5,this.m_body._y - this.m_height * 0.5);
  42.    }
  43.    function get _bottomRightCorner()
  44.    {
  45.       return new Vector2D(this.m_body._x + this.m_width * 0.5,this.m_body._y + this.m_height * 0.5);
  46.    }
  47.    function get _left()
  48.    {
  49.       return this.m_body._x - this.m_width * 0.5;
  50.    }
  51.    function get _right()
  52.    {
  53.       return this.m_body._x + this.m_width * 0.5;
  54.    }
  55.    function get _top()
  56.    {
  57.       return this.m_body._y - this.m_height * 0.5;
  58.    }
  59.    function get _bottom()
  60.    {
  61.       return this.m_body._y + this.m_height * 0.5;
  62.    }
  63.    function set _topLeftCorner(corner)
  64.    {
  65.       this.m_width = (this.m_body._x - corner._x) * 2;
  66.       this.m_height = (this.m_body._y - corner._y) * 2;
  67.    }
  68.    function set _bottomRightCorner(corner)
  69.    {
  70.       this.m_width = (corner._x - this.m_body._x) * 2;
  71.       this.m_height = (corner._y - this.m_body._y) * 2;
  72.    }
  73.    function set _left(value)
  74.    {
  75.       this.m_width = (this.m_body._x - value) * 2;
  76.    }
  77.    function set _right(value)
  78.    {
  79.       this.m_width = (value - this.m_body._x) * 2;
  80.    }
  81.    function set _top(value)
  82.    {
  83.       this.m_height = (this.m_body._y - value) * 2;
  84.    }
  85.    function set _bottom(value)
  86.    {
  87.       this.m_height = (value - this.m_body._y) * 2;
  88.    }
  89. }
  90.